﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Wix.Aura.Common;
using Wix.Aura.UnitTests.Tools;
using Wix.Aura.Common.CustomTypes;

namespace Wix.Aura.UnitTests.Common {
	[TestFixture]
	public class PermissionSerialization {
		[SetUp]
		public void SetUp() {
			permission = new Permission("Daniel");
		}

		Permission permission;

		[Test]
		public void EmptyPermission() {
			
			XmlAssert.AreEqual(@"<Permission User=""Daniel"" />", permission);
		}

		[Test]
		public void AllAttributes() {
			permission.Append = YesNoType.Yes;
			permission.ChangePermission = YesNoType.Yes;
			permission.CreateChild = YesNoType.Yes;
			permission.CreateFile = YesNoType.Yes;
			permission.CreateLink = YesNoType.Yes;
			permission.CreateSubkeys = YesNoType.Yes;
			permission.Delete = YesNoType.Yes;
			permission.DeleteChild = YesNoType.Yes;
			permission.Domain = "Domain";
			permission.EnumerateSubkeys = YesNoType.Yes;
			permission.Execute = YesNoType.Yes;
			permission.FileAllRights = YesNoType.Yes;
			permission.GenericAll = YesNoType.Yes;
			permission.GenericExecute = YesNoType.Yes;
			permission.GenericRead = YesNoType.Yes;
			permission.GenericWrite = YesNoType.Yes;
			permission.Notify = YesNoType.Yes;
			permission.Read = YesNoType.Yes;
			permission.ReadAttributes = YesNoType.Yes;
			permission.ReadExtendedAttributes = YesNoType.Yes;
			permission.ReadPermission = YesNoType.Yes;
			permission.SpecificRightsAll = YesNoType.Yes;
			permission.Synchronize = YesNoType.Yes;
			permission.TakeOwnership = YesNoType.Yes;
			permission.Traverse = YesNoType.Yes;
			permission.Write = YesNoType.Yes;
			permission.WriteAttributes = YesNoType.Yes;
			permission.WriteExtendedAttributes = YesNoType.Yes;

			XmlAssert.AreEqual(@"<Permission User=""Daniel"" Append=""yes"" ChangePermission=""yes"" CreateChild=""yes"" CreateFile=""yes"" CreateLink=""yes"" 
CreateSubkeys=""yes"" Delete=""yes"" DeleteChild=""yes"" Domain=""Domain"" EnumerateSubkeys=""yes"" Execute=""yes"" FileAllRights=""yes"" GenericAll=""yes"" GenericExecute=""yes"" 
GenericRead=""yes"" GenericWrite=""yes"" Notify=""yes"" Read=""yes"" ReadAttributes=""yes"" ReadExtendedAttributes=""yes"" ReadPermission=""yes"" SpecificRightsAll=""yes"" 
Synchronize=""yes"" TakeOwnerShip=""yes"" Traverse=""yes"" Write=""yes"" WriteAttributes=""yes"" WriteExtendedAttributes=""yes""/>", permission);
		}
	}
}
